-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: "spacers" #12
base: main
Are you sure you want to change the base?
feat: "spacers" #12
Conversation
- can be used to give centering by adding spacers at top and bottom - can be used to give top and bottom aligned sections with spacer in the middle
why does this have to maintain state and move around cursor jumps? if i'm understanding the purpose of this widget correctly couldn't you just do arithmetic to calculate a percentage of the window height and then call |
ah, this is why. 🤔 |
The reason is that you need to do this after all of the other I suppose you could combine this into the |
I'm happy to change methodology if you would prefer a different setup (e.g. I wasn't 100% happy with the naming "spacer" but couldn't think of anything better). |
well, as far as vim goes drawing blank lines at the end of an unmodifiable buffer is pretty pointless, but if you used a spacer in the middle then yeah you would need to go back and adjust the space drawn at the beginning |
Yeh, I thought about the blank lines at the end being pointless, but I also thought that doing an extra check in the loop would make the implementation more confusing, and since it was doing no harm, I left it as is. |
can we iterate over the layout before |
keeping rendering happening from top to bottom sequentially just makes the state space of the program easier to think about |
I agree that rendering from top to bottom makes things easier to think about 👍 We would just need to be careful about calculating sizes of elements before we render them. It's probably doable, but would just need some careful thought. |
- only calculates cursor jumps based on final rendered position - also reorganised `text` type resolving
@goolord Any thoughts? |
seems better, i will give this a closer look when i have time |
e7b2cc3
to
1356b9e
Compare
This PR adds a new type of
layout_element
, a "spacer", which (if there is additional space on screen once everything else is drawn) fills the remaining space.Multiple spacers can be used at once to give a "vertically centered" layout (one spacer at the top, one at the bottom).
You can also put a spacer in the middle to have a top aligned block and a bottom aligned block.
The spacers are adjustable by changing their
val
, which changes the ratio of their size in relation to the other spacers.I think I have managed to get it to work with everything else (e.g.
cursor_jumps
) properly but would be good to have other people testing.